import numpy as np
import cv2
import torch
import PIL.Image as pil
import matplotlib as mpl
import matplotlib.cm as cm


npz_path = './splits/eigen/gt_depths.npz'

f = np.load(npz_path)
data = f['data'][1]
# print(data.shape)
# data = torch.from_numpy(data)
#
disp_resized_np = data
# # disp_resized_np = data.squeeze().cpu().numpy()
# vmax = np.percentile(disp_resized_np, 95)
# normalizer = mpl.colors.Normalize(vmin=disp_resized_np.min(), vmax=vmax)
# mapper = cm.ScalarMappable(norm=normalizer, cmap='magma')
# colormapped_im = (mapper.to_rgba(disp_resized_np)[:, :, :3] * 255).astype(np.uint8)
# im = pil.fromarray(colormapped_im)
# im.show()



im_color=cv2.applyColorMap(cv2.convertScaleAbs(data,alpha=15),cv2.COLORMAP_TURBO)
im_color = pil.fromarray(im_color)
im_color.show()


# cv2.imshow("1",img)	#显示一张图片
# cv2.waitKey()		#必须加上，不然图片无法显示
# cv2.destroyAllWindows()